package org.example.controller.admin;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.Dianpu;
import org.example.entity.Employee;
import org.example.entity.Shanpin;
import org.example.result.Result;
import org.example.service.DianpuService;
import org.example.service.ShanpinService;
import org.example.service.ShanpinfeleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/dianpu")
@Slf4j
@Api(tags = "店铺相关接口")
public class EmployeedianpuController {
    @Autowired
    DianpuService dianpuService;
    @Autowired
    ShanpinfeleService shanpinfeleService;


    /**
     * 店铺查询
     *
     * @param
     * @return
     */
    @GetMapping("/toucx")
    @ApiOperation(value = "店铺查询")
    public Result<Dianpu> toucx(@RequestParam("username") String username) {
        log.info("店铺查询：{}");

        return Result.success(dianpuService.dianpucx(username));

    }


    /**
     * 店铺分类查询
     *
     * @param
     * @return
     */
    @GetMapping("/shanpinfele")
    @ApiOperation(value = "分类查询")
    public Result<String[]> shanpinfelecx(@RequestParam("username") String username) {
        log.info("分类查询：{}");

        return Result.success(shanpinfeleService.feleplnamecx(username));

    }


    /**
     * 店铺商品查询
     *
     * @param
     * @return
     */
    @GetMapping("/shanpincx")
    @ApiOperation(value = "店铺商品查询")
    public Result<List<Shanpin>> shanpincx(@RequestParam("username") String username,
                                           @RequestParam("felename") String felename,
                                           @RequestParam("souso") String souso) {
        log.info("店铺商品查询：{},{}", username, felename);
        return Result.success(dianpuService.shanpincx(username, felename, souso));

    }


    /**
     * 店铺关注查询
     *
     * @param
     * @return
     */
    @GetMapping("/gzcx")
    @ApiOperation(value = "店铺关注查询")
    public Result gzdinpudancx(@RequestParam("dianpuusername") String dianpuusername
            , @RequestParam("yonghuusername") String yonghuusername) {
        log.info("店铺关注查询：{}", dianpuusername);
        if (dianpuService.gzcx(dianpuusername, yonghuusername) != null)
            return Result.success();
        else
            return Result.error("失败");

    }

    /**
     * 店铺关注修改
     *
     * @param
     * @return
     */
    @PutMapping("/gzxg")
    @ApiOperation(value = " 店铺关注修改")
    public Result dianpudanxg(@RequestParam("dianpuusername") String dianpuusername
            , @RequestParam("yonghuusername") String yonghuusername) {
        log.info(" 店铺关注修改：{}", dianpuusername);
        dianpuService.gzxg(dianpuusername, yonghuusername);
        return Result.success();
    }

    /**
     * 店铺关注查询总
     *
     * @param
     * @return
     */
    @GetMapping("/gzdianpucx")
    @ApiOperation(value = "店铺关注查询总")
    public Result<List<Dianpu>> gzdinpucx(@RequestParam("yonghuusername") String yonghuusername) {
        log.info("店铺关注查询：{}", yonghuusername);
        return Result.success(dianpuService.gzdianpucx(yonghuusername));

    }


    /**
     * 店铺关注查询总
     *
     * @param
     * @return
     */
    @GetMapping("/dianpucx")
    @ApiOperation(value = "店铺查询总")
    public Result<List<Dianpu>> dianpucx(@RequestParam("souso") String souso,
                                         @RequestParam("yonghuusername") String yonghuusername) {
        log.info("店铺查询总：{}",souso);
        return Result.success(dianpuService.dianpucxs(souso,yonghuusername));
    }





}
